package com.government.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.government.common.annotation.Log;
import com.government.common.core.controller.BaseController;
import com.government.common.core.domain.AjaxResult;
import com.government.common.enums.BusinessType;
import com.government.system.domain.Guestbook;
import com.government.system.service.IGuestbookService;
import com.government.common.utils.poi.ExcelUtil;
import com.government.common.core.page.TableDataInfo;

/**
 * 留言板Controller
 *
 * @author system
 * @date 2023-11-15
 */
@RestController
@RequestMapping("/system/guestbook")
public class GuestbookController extends BaseController
{
    @Autowired
    private IGuestbookService guestbookService;

    /**
     * 查询留言板列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Guestbook guestbook)
    {

        List<Guestbook> list = guestbookService.selectGuestbookList(guestbook);
        return getDataTable(list);
    }

    /**
     * 获取留言板详细信息
     */
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfo(Long userId)
    {
        return success(guestbookService.selectGuestbookByUserId(userId));
    }

    /**
     * 新增留言板
     */
    @Log(title = "留言板", businessType = BusinessType.INSERT)
    @PostMapping(value = "/insertGuestbook")
    public AjaxResult insertGuestbook(@RequestBody Guestbook guestbook)
    {
        return toAjax(guestbookService.insertGuestbook(guestbook));
    }

}
